// Copyright (c) 2009 John Ehn, ExtremeSwank.com
//
// Permission is hereby granted, free of charge, to any person
// obtaining a copy of this software and associated documentation
// files (the "Software"), to deal in the Software without
// restriction, including without limitation the rights to use,
// copy, modify, merge, publish, distribute, sublicense, and/or sell
// copies of the Software, and to permit persons to whom the
// Software is furnished to do so, subject to the following
// conditions:
//
// The above copyright notice and this permission notice shall be
// included in all copies or substantial portions of the Software.
//
// THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND,
// EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES
// OF MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND
// NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT
// HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY,
// WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING
// FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR
// OTHER DEALINGS IN THE SOFTWARE.

using System;
using System.Collections.Specialized;
using ExtremeSwank.OpenId.PlugIns.Discovery;

namespace ExtremeSwank.OpenId
{
    /// <summary>
    /// Interface used for Extension plugins. 
    /// Extension plugins extend the OpenID Consumer to support additional data-passing specifications.
    /// </summary>
    public interface IExtension
    {
        /// <summary>
        /// Human-readable name of plugin.
        /// </summary>
        string Name { get; }
        /// <summary>
        /// Parent <see cref="StateContainer"/> StateContainer object.
        /// </summary>
        StateContainer Parent { get; }
        /// <summary>
        /// Advertised namespace this plug-in supports.
        /// </summary>
        Uri NamespaceUri { get; }
        /// <summary>
        /// Data to be passed to Identity Provider during initial
        /// authenticaton request.
        /// </summary>
        NameValueCollection BuildAuthorizationData(DiscoveryResult discResult);
        /// <summary>
        /// Perform any additional checking that needs to occur during validation.
        /// </summary>
        /// <remarks>If the extension should not perform validation, always return true.</remarks>
        /// <returns>Returns true if validation is successful, false if not.</returns>
        bool Validation();
        /// <summary>
        /// Populate a give OpenIdUser object with extension data received from 
        /// the OpenID Provider.
        /// </summary>
        void PopulateUserObject(OpenIdUser userObject);
    }
}
